def loop_test():
    # 计算从1-100 的和值
    num = 100
    result = 0
    for i in range(1, num + 1):
        result += i
    print(result)
    # 从如下list中遍历所有数据
    my_list = ['apple', 'banana', 'cherry']
    for item in my_list:
        print(item)
    # 选择自己喜欢的天
    weekdays_list = ['Monday', 'Tuesday', '星期三', 'thursday', 'friday']
    for i in range(0, len(weekdays_list) - 1, 2):
        like_day = weekdays_list[i + 1]
        print('i like days is : ', like_day)
    # 打印9*9乘法表
    for i in range(1, 10):
        for j in range(1, i + 1):
            print(j, '*', i, '=', i * j, end='\t')
        print('')
    print('班级 \t', '姓名 \t', '成绩 \t')
    info = ['1班', 'peter', 90]
    # for i in range(0, 4):
    #     for j in range(len(info)):
    #         print(info[j], end='\t |')
    #     print('')
    stu_data = [
        {'classNo': '一班', "name": "peter", "score": 90},
        {'classNo': '二班', "name": "Amalie", "score": 92},
        {'classNo': '三班', "name": "Jack", "score": 98},
    ]
    for data in stu_data:
        # print(data)
        for key, value in data.items():
            print(value, end="\t\t ")
        print("")


def order_list():
    order_data = [
        {"sku": "60256171", "sku_nane": "面条", "unit": "包", "price": 10.5, "quantity": 15},
        {"sku": "60256172", "sku_nane": "辣条", "unit": "包", "price": 15.5, "quantity": 20},
        {"sku": "60256173", "sku_nane": "牙签", "unit": "盒", "price": 10.5, "quantity": 10},
        {"sku": "60256174", "sku_nane": "香烟", "unit": "包", "price": 30.5, "quantity": 20},
        {"sku": "60256175", "sku_nane": "杯子", "unit": "个", "price": 50.5, "quantity": 15}

    ]
    print("商品编码\t\t", "商品名称\t\t", "单位\t", "价格\t", "数量\t", "小计\t\t")
    total_amount = 0
    for order in order_data:
        order["total_price"] = order["price"] * order["quantity"]
        for key, value in order.items():
            print(value, end="\t\t ")
        print("")
        total_amount += order["total_price"]
    print("您应该支付\t\t", total_amount)


# 求1-50内数据的之和
def data_sum(num):
    result = 0
    for i in range(1, num + 1):
        if i % 2 != 0:
            result += i
    print(result, end="\t\t \n")


# 99乘法
def nine():
    for i in range(1, 10):
        for j in range(1, i + 1):
            print(j, "*", i, "=", i * j, end="\t")
        print("")


def stu_info(num):
    stu_list = []
    for i in range(0, num):
        name = input("请输入第({})个学生的姓名：".format(i+1))
        score = input("他的得分是：")
        stu_dic = {"name": name, "score": score}
        stu_list.append(stu_dic)

    # stu_list.append("peter")
    print(stu_list)


if __name__ == '__main__':
    order_list()
    data_sum(100)
    nine()
    stu_count = input("请输入您班级的人数：")
    stu_info(int(stu_count))
